package com.bJian.bJIanOJ.judge;

import com.bJian.bJIanOJ.judge.strategy.DefaultJudgeStrategy;
import com.bJian.bJIanOJ.judge.strategy.JudgeContext;
import com.bJian.bJIanOJ.judge.strategy.JudgeStrategy;
import com.bJian.bJIanOJ.model.dto.question_submit.JudgeInfo;
import com.bJian.bJIanOJ.model.entity.question_submit;
import org.springframework.stereotype.Component;

@Component
public class JudgeManager {
    /**
     * 执行判题
     *
     * @param judgeContext
     * @return
     */
    JudgeInfo doJudge(JudgeContext judgeContext) {
        question_submit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        //todo 以下代码根据语言选择对应的判题策略
//        if ("java".equals(language)) {
//            judgeStrategy = new JavaLanguageJudgeStrategy();
//        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
